package com.wikidot.designpatterns.abstractfactory;

/**
 * Abstract Factory
 */
abstract class FoodFactory {
	/**
	 * Products that are possible to build with the factory. In general, there
	 * might be more factory initialization parameters and these can be provided
	 * in various ways. Here, for simplicity, product portfolio is declared
	 * statically.
	 */
	enum FactoryPortfolio {
		BREAD, CAKE;
	}

	/**
	 * This will return specific factory based on value of the parameter.
	 * 
	 * @param parameter
	 *            Variable that decides which concrete factory will be created.
	 */
	public static FoodFactory getFactory(FactoryPortfolio parameter) {
		FoodFactory factory = null;
		switch (parameter) {
		case BREAD:
			factory = new BreadFactory();
			break;
		case CAKE:
			factory = new CakeFactory();
			break;
		}
		return factory;
	}

	/**
	 * This method must be implemented by concrete factory. The concrete product
	 * is determined also by concrete factory but must inherit from given
	 * superclass.
	 * 
	 * @return
	 */
	public abstract Food getProduct();
}
